package com.example.consumer.service;

import com.example.common.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Service
public class OrderService {

    @Resource
    private RestTemplate restTemplate;

    @DubboReference
    private UserService userService;

    public String getUser(){
        String result = restTemplate.getForObject("http://127.0.0.1:8081/user",String.class);
        return "Order调用返回值"+result;
    }

    public String getDubboUser(){

        return "OrderDubbo调用返回值"+userService.getUser();
    }
}
